package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.WorkflowService;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.Workflow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ Description:
 * @ Author: DuYaTao
 * @ Date: 2025/9/18 - 18:59
 */

@RestController
@RequestMapping("/workflow")
public class WorkflowController {

    @Autowired
    private WorkflowService workflowService;

    @GetMapping("/page")
    public Result<PageInfo<Workflow>> selectList(Workflow workflow,int page, int size){
        return workflowService.selectList(workflow,page,size);
    }

    @GetMapping("/code/{code}")
    public Result<Workflow> selectByCode(@PathVariable String code){
        return workflowService.selectByWorkflowCode(code);
    }

    @PostMapping("/add")
    public Result<Workflow> add(@RequestBody Workflow workflow){
        return workflowService.addWorkflow(workflow);
    }

    @PutMapping("/update")
    public Result<Workflow> update(@RequestBody Workflow workflow){
        return workflowService.updateWorkflow(workflow);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Workflow> deleteById(@PathVariable Integer id){
        return workflowService.deleteWorkflow(id);
    }

    @DeleteMapping("/batchDelete")
    public Result<List<Workflow>> batchDeleteByIds(@RequestBody Integer[] id){
        return workflowService.batchDelete(id);
    }
}
